import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pplive/pages/home/home_page.dart';
import 'package:pplive/pages/mine/mine_page.dart';
import 'package:pplive/pages/square/square_page.dart';

import '../../common/utils.dart';

class MainPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _MainPageState();
  }
}

class _MainPageState extends State<MainPage> {
  final List pages = [HomePage(), SquarePage() ,MinePage()];
  int index = 0;

  @override
  Widget build(BuildContext context) {
    Util.shared().theme = Theme.of(context); 
    return Scaffold(
      body: pages[index],
      bottomNavigationBar: BottomNavigationBar(
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
          BottomNavigationBarItem(icon: Icon(Icons.square), label: 'Square'),
          BottomNavigationBarItem(icon: Icon(Icons.settings), label: 'Mine')
        ],
        currentIndex: index,
        selectedItemColor: Colors.grey.withOpacity(0.5),
        showSelectedLabels: false,
        showUnselectedLabels: false,
        elevation: 0,
        onTap: (value) => setState(() => index = value),
      ),
    );
  }
}
